package com.zjeav.lingjiao.base.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zjeav.lingjiao.R;
import com.zjeav.lingjiao.base.baseBean.Book;
import com.zjeav.lingjiao.base.baseBean.Metadata;
import com.zjeav.lingjiao.base.utils.StringUtils;

import java.util.List;

public class FavorriteBookAdapter extends BaseQuickAdapter<Metadata, BaseViewHolder> {
    private Context context;

    public FavorriteBookAdapter(Context context) {
        super(R.layout.favorites_item);
        this.context = context;

    }

    @Override
    protected void convert(BaseViewHolder helper, Metadata item) {

        String strtimelenght  ="";
        String strfilesize  ="";
        if (StringUtils.isNullOrEmpty(String.valueOf(item.getDuration()))){
            strtimelenght = "";
        }else {

            long a=item.getDuration();
            long b=60;
            strtimelenght = (a/b)+":"+(a%b);
        }

        if (StringUtils.isNullOrEmpty(item.getFilesize())){
            strfilesize = "";
        }else {
            strfilesize = item.getFilesize();
        }

        helper.setText(R.id.book_title_txt, item.getTitle());
        helper.setText(R.id.time_txt, item.getFavoritesTime());
        helper.setText(R.id.duration_txt,strtimelenght);
        helper.setText(R.id.size_txt,strfilesize);
        helper.setImageResource(R.id.selected_img, R.mipmap.choos_sel_copy_5);
        ImageView imageView = helper.getView(R.id.yinp_img);
        Glide.with(context)
                .load(item.getCover())
                .into(imageView);

//
    }
}
